<?php

// +----------------------------------------------------------------------

// | Description: 客户

// +----------------------------------------------------------------------

// | Author: zl

// +----------------------------------------------------------------------



namespace app\crm\controller;



use app\admin\controller\ApiCommon;

use app\crm\model\Customer as CustomerModel;
use app\crm\model\CustomerConfig as CustomerConfigModel;
use app\crm\model\AddCaseModel;

use think\response\Json;

use think\facade\Db;

use think\facade\Request;

class AddCase extends ApiCommon

{
    
    protected $customerModel;

    protected $customerConfigModel;

    /**

     * 用于判断权限

     * @permission 无限制

     * @allow 登录用户可访问

     * @other 其他根据系统设置

     **/

    public function initialize()

    {

        $action = [

            'permission' => ['add_question'],

            'allow' => ['users', 'info']

        ];

        event('CheckAuth',$action);

        $request = $this->request;

        $a = strtolower($request->action());



        $this->customerModel = new CustomerModel();

        $this->customerConfigModel = new CustomerConfigModel();

        if (!in_array($a, $action['permission'])) {

            parent::initialize();

        }

    }
    
    public function customerAddCase(){

        $request = $this->param;
        

        $model = new AddCaseModel();

        $data = $model->AddCustomerCase($request);

        if (!$data) {
            return resultArray(['error' => $customerModel->getError()]);
        }
        return resultArray(['data' => $data]);

        
    }

}